package com.example.child_protection.controller;

import com.example.child_protection.dto.base.BaseResponseDTO;
import com.example.child_protection.dto.request.SimpleIdRequestDTO;
import com.example.child_protection.dto.request.add.SystemMenuInsertRequestDTO;
import com.example.child_protection.dto.request.find.SystemMenuRequestDTO;
import com.example.child_protection.dto.request.update.SystemMenuUpdateRequestDTO;
import com.example.child_protection.dto.response.SystemMenuListResponseDTO;
import com.example.child_protection.service.SystemMenuManageService;
import com.example.child_protection.service.SystemMenuQueryService;
import com.example.child_protection.util.ContentType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 菜单信息管理控制层
 * @date 2018-11-2
 * @author Biz
 */
@RestController
@RequestMapping("systemMenu")
@Api(value = "/api-systemMenu", description = "菜单信息管理")
public class SystemMenuController extends BaseController {

    @Autowired
    public SystemMenuManageService systemMenuManageService;

    @Autowired
    public SystemMenuQueryService systemMenuQueryService;

    @ApiOperation(value ="查询菜单信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/findList", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public SystemMenuListResponseDTO findList(SystemMenuRequestDTO requestDTO)throws Exception{
        SystemMenuListResponseDTO responseDTO = systemMenuQueryService.findList(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="查询角色菜单列表信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/findRoleMenuList", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public SystemMenuListResponseDTO findRoleMenuList(SystemMenuRequestDTO requestDTO)throws Exception{
        SystemMenuListResponseDTO responseDTO = systemMenuQueryService.findRoleMenuList(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="添加菜单信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/insert", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO insert(SystemMenuInsertRequestDTO requestDTO)throws Exception{
        requestDTO.setCreatePersonId(getLoginUserId());
        requestDTO.setLastUpdatePersonId(getLoginUserId());
        BaseResponseDTO responseDTO = systemMenuManageService.insert(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="修改菜单信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/update", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO update(SystemMenuUpdateRequestDTO requestDTO)throws Exception{
        requestDTO.setLastUpdatePersonId(getLoginUserId());
        BaseResponseDTO responseDTO = systemMenuManageService.update(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="删除菜单信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO delete(SimpleIdRequestDTO requestDTO)throws Exception{
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemMenuManageService.delete(requestDTO);
        return responseDTO;
    }

}
